/*
 * SD.c
 *
 * Created: 2012-10-05 21:44:06
 *  Author: DEEPSPACE
 */ 
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <string.h>
#include <avr/delay.h>

#include "pff.h"

enum NETWORK_ID
{
	MESSAGE_OK		= 0b00000001,
	MESSAGE_ERROR	= 0b00000010,
	MESSAGE_DATA	= 0b00000100,
	MESSAGE_EVENT	= 0b00001000,
	MESSAGE_STAGE	= 0b00010000
};

uint8_t dataReceived = 0;
uint8_t temp[1];

FATFS fs;			/* File system object */
DIR dir;			/* Directory object */
FILINFO fno;		/* File information */
BYTE res;

char filename[] = "kalle.txt\0"; 

int main(void)
{
	initUSART();
	sei();
	res = disk_initialize();		//Ska returnera 0 = OK
	SendData(&res,1);				//works
	_delay_ms(1000);
	
	res = pf_mount(&fs);			//Ska returnera 0 = ok
	SendData(&res,1);				//works
	_delay_ms(1000);
	
	res = pf_open(&filename);		//ska retunera 0 = ok
	SendData(&res,1);				//returnerar 3 = FR_NO_FILE
	_delay_ms(1000);
    while(1)
    {
        //TODO:: Please write your application code 
    }
}

//typedef enum {
//	FR_OK = 0,			/* 0 */
//	FR_DISK_ERR,		/* 1 */
//	FR_NOT_READY,		/* 2 */
//	FR_NO_FILE,			/* 3 */
//	FR_NO_PATH,			/* 4 */
//	FR_NOT_OPENED,		/* 5 */
//	FR_NOT_ENABLED,		/* 6 */
//	FR_NO_FILESYSTEM	/* 7 */
//} FRESULT;